<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Configurações IAX</title>
<link href="css/conf.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

	function sectionTypeOnChange(){
	
		var combo = document.getElementById("sectionType");
		
		var general = document.getElementById("general");
		var outros = document.getElementById("outros");
		
		if (combo.value == "general" ) {
			general.style.display = "block";
			outros.style.display = "none";
			
			document.getElementById("id").value = "general";
		
		} else {
			general.style.display = "none";
			outros.style.display = "block";
			
			document.getElementById("id").value = "";
		}
	}

</script>

</head>

<body bgcolor="#c0c0c0">

	<div align="center">
		<h2>Configuração Iax</h2>
		<h6>
			<a href="menu.jsp">Voltar ao Menu</a>
		</h6>
	</div>

	<form action='IaxController' name='controle'>

		<table width="527" border="0" align="center"
			cellpadding="1" cellspacing="1">

				<tr>
					<td colspan="2"><span class="submenus">Tipo de Seção: </span>
						<select id="sectionType" name="sectionType" onchange="sectionTypeOnChange();">
							<c:choose>
								<c:when test="${empty obj || (! empty obj && obj.id == 'general')}">
								
									<option value="general" selected="selected">General</option>
									<option value="">Outros</option>
									
									<c:set var="displayGeneral" value="block"></c:set>
									<c:set var="displayOutros" value="none"></c:set>
								
								</c:when>
								<c:otherwise>
								
									<option value="general">General</option>
									<option value=""  selected="selected">Outros</option>
								
									<c:set var="displayGeneral" value="none"></c:set>
									<c:set var="displayOutros" value="block"></c:set>
								
								</c:otherwise>
							</c:choose>
						</select>
					</td>
				</tr>
				
				<tr>
					<td colspan="2">
						<div id="general" style="display: ${displayGeneral};">
							<table>
								
								<tr>
									<td><span class="submenus">Bandwidth =</span></td>
									<td height="23"><span class="submenus"><input
											type='text' name='bandWidth' id="bandWidth" />
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">Disallow =</span></td>
									<td height="23"><span class="submenus"><input
											type='text' name='disallow' id="disallow" />
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">Jitter Buffer =</span></td>
									<td height="23"><span class="submenus">
									
										<select id="jitterBuffer" name="jitterBuffer">
											<c:choose>
												<c:when test="${obj.jitterBuffer == 'yes'}">
													<option value=""></option>
													<option value="yes" selected="selected">Yes</option>
													<option value="no">No</option>
												</c:when>
												<c:when test="${obj.jitterBuffer == 'no'}">
													<option value=""></option>
													<option value="yes">Yes</option>
													<option value="no" selected="selected">No</option>
												</c:when>
												<c:otherwise>
													<option value="" selected="selected"></option>
													<option value="yes">Yes</option>
													<option value="no">No</option>
												</c:otherwise>
											</c:choose>
										</select>
									
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">Force Jitter Buffer =</span></td>
									<td height="23"><span class="submenus">
									
										<select id="forceJitterBuffer" name="forceJitterBuffer">
											<c:choose>
												<c:when test="${obj.forceJitterBuffer == 'yes'}">
													<option value=""></option>
													<option value="yes" selected="selected">Yes</option>
													<option value="no">No</option>
												</c:when>
												<c:when test="${obj.forceJitterBuffer == 'no'}">
													<option value=""></option>
													<option value="yes">Yes</option>
													<option value="no" selected="selected">No</option>
												</c:when>
												<c:otherwise>
													<option value="" selected="selected"></option>
													<option value="yes">Yes</option>
													<option value="no">No</option>
												</c:otherwise>
											</c:choose>
										</select>
										
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">TOS =</span></td>
									<td height="23"><span class="submenus"><input
											type='text' name='tos' id="tos" />
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">Auto Kill =</span></td>
									<td height="23"><span class="submenus">
									
										<select id="autoKill" name="autoKill">
											<c:choose>
												<c:when test="${obj.autoKill == 'yes'}">
													<option value=""></option>
													<option value="yes" selected="selected">Yes</option>
													<option value="no">No</option>
												</c:when>
												<c:when test="${obj.autoKill == 'no'}">
													<option value=""></option>
													<option value="yes">Yes</option>
													<option value="no" selected="selected">No</option>
												</c:when>
												<c:otherwise>
													<option value="" selected="selected"></option>
													<option value="yes">Yes</option>
													<option value="no">No</option>
												</c:otherwise>
											</c:choose>
										</select>
										
									</span></td>
								</tr>
								
							</table>
						</div>
					</td>
				</tr>
				
				
				<tr>
					<td colspan="2">
						<div id="outros" style="display: ${displayOutros};">
							<table>
								<tr>
									<td><span class="submenus">Seção =</span></td>
									<td height="23"><span class="submenus">[ <input
											type='text' name='id' maxlength="4" size="4" id="id" /> ]
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Caller ID =</span></td>
									<td height="23"><span class="submenus"> <input
											type='text' name='callerId' id="callerId" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Type =</span></td>
									<td><span class="submenus"> <input type='text'
											name='type' id="type" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Username =</span></td>
									<td><span class="submenus"> <input type='text'
											name='userName' id="userName" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Secret =</span></td>
									<td><span class="submenus"> <input type='text'
											name='secret' id="secret" />
									</span></td>
								</tr>
					            <tr>
									<td><span class="submenus">Context =</span></td>
									<td><span class="submenus"> <input type='text'
											name='context' id="context" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Host =</span></td>
									<td><span class="submenus"> <input type='text'
											name='host' id="host" />
									</span></td>
								</tr>
								
								<tr>
									<td><span class="submenus">Auth =</span></td>
									<td><span class="submenus"> <input type='text'
											name='auth' id="auth" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Transfer =</span></td>
									<td><span class="submenus"> <input type='text'
											name='transfer' id="transfer" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Allow =</span></td>
									<td><span class="submenus"> <input type='text'
											name='allow' id="allow" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">DB Secret =</span></td>
									<td><span class="submenus"> <input type='text'
											name='dbsecret' id="dbsecret" />
									</span></td>
								</tr>
								<tr>
									<td><span class="submenus">Trunk =</span></td>
									<td><span class="submenus"> 
									
										<select id="trunk" name="trunk">
											<c:choose>
												<c:when test="${obj.trunk == 'yes'}">
													<option value=""></option>
													<option value="yes" selected="selected">Yes</option>
													<option value="no">No</option>
												</c:when>
												<c:when test="${obj.trunk == 'no'}">
													<option value=""></option>
													<option value="yes">Yes</option>
													<option value="no" selected="selected">No</option>
												</c:when>
												<c:otherwise>
													<option value="" selected="selected"></option>
													<option value="yes">Yes</option>
													<option value="no">No</option>
												</c:otherwise>
											</c:choose>
										</select>
										
									</span></td>
								</tr>
							</table>
						</div>
					</td>
				</tr>

			<tr>
				<td colspan="2" align="center" valign="bottom"><input type='submit'
					class="textoBolt" value='Confirmar' /></td>
			</tr>


		</table>

		<p>&nbsp;</p>

		<input type="hidden" name="act" id="act" value="${requestScope.act}" />

	</form>
	
	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="10" style="background-color: lightgrey"><b>GENERAL</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td width="14%"><strong>Band Width</strong></td>
			<td width="14%"><strong>Disallow</strong></td>
			<td width="14%"><strong>Jitter Buffer</strong></td>
			<td width="14%"><strong>Force Jitter Buffer</strong></td>
			<td width="14%"><strong>TOS</strong></td>
			<td width="16%"><strong>Auto Kill</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
		</tr>
	
		<tbody>
			<c:forEach items="${requestScope.lista}" var="iax" >
			
				<c:if test="${iax.id == 'general'}">
					<tr>
						<td>${iax.bandWidth}</td>
						<td>${iax.disallow}</td>
						<td>${iax.jitterBuffer}</td>
						<td>${iax.forceJitterBuffer}</td>
						<td>${iax.tos}</td>
						<td>${iax.autoKill}</td>
						
						<td width="52"><input name="Deletar2" type="submit" class="rodape" id="Deletar2" value="Alterar" onclick="document.location.href='IaxController?act=retrieve&id=${iax.id}'"/></td>
						<td width="56"><input name="Deletar" type="submit" class="rodape" id="Deletar" value="Deletar" onclick="document.location.href='IaxController?act=delete&id=${iax.id}'"/></td>
					</tr>
				</c:if>
				
			</c:forEach>
		</tbody>

	</table>

	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="14" style="background-color: lightgrey"><b>SECTIONS</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td width="8%"><strong>Seção</strong></td>
			<td width="8%"><strong>Caller ID</strong></td>
			<td width="8%"><strong>Type</strong></td>
			<td width="8%"><strong>Username</strong></td>
			<td width="7%"><strong>Secret</strong></td>
			<td width="7%"><strong>Context</strong></td>
            <td width="7%"><strong>Host</strong></td>
			<td width="7%"><strong>Auth</strong></td>
			<td width="7%"><strong>Transfer</strong></td>
			<td width="7%"><strong>Allow</strong></td>
			<td width="7%"><strong>DB Secret</strong></td>
			<td width="7%"><strong>Trunk</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
		</tr>
	
		<c:forEach items="${requestScope.lista}" var="iax" >

			<c:if test="${iax.id != 'general'}">
				<tr>
					<td>${iax.id}</td>
					<td>${iax.callerId}</td>
					<td>${iax.type}</td>
					<td>${iax.userName}</td>
					<td>${iax.secret}</td>
					<td>${iax.context}</td>
                    <td>${iax.host}</td>
					<td>${iax.auth}</td>
					<td>${iax.transfer}</td>
					<td>${iax.allow}</td>
					<td>${iax.dbSecret}</td>
					<td>${iax.trunk}</td>
					
					<td width="52"><input name="Deletar2" type="submit" class="rodape" id="Deletar2" value="Alterar" onclick="document.location.href='IaxController?act=retrieve&id=${iax.id}'"/></td>
					<td width="56"><input name="Deletar" type="submit" class="rodape" id="Deletar" value="Deletar" onclick="document.location.href='IaxController?act=delete&id=${iax.id}'"/></td>
				</tr>
			</c:if>

		</c:forEach>

	</table>
</body>

</html>
